cmake_minimum_required(VERSION 2.6)
PROJECT(wishmaster)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
SET(MODULE_PATH "${CMAKE_ROOT}/Modules")

#SET(CMAKE_BUILD_TYPE Profile)
SET(CMAKE_CXX_FLAGS  "-O2 -Wall -g --std=c++0x -fPIC")

# Boost stuff:

#set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_STATIC_RUNTIME OFF)
set (Boost_USE_MULTITHREADED ON)

find_package(Boost COMPONENTS system regex thread REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

find_package(Threads REQUIRED)

INCLUDE_DIRECTORIES( ${.} sqlite3 ..)

SET(wishmaster_sources
	analyzers/analyzer.cpp
	analyzers/extractor.cpp
	analyzers/raranalyzer.cpp
	analyzers/zipanalyzer.cpp
	boardparsers/boardparser.cpp
	boardparsers/parserfactory.cpp
	captchafetchers/captchafetcherfactory.cpp
	captchafetchers/genericcaptchafetcher.cpp
	chanagents/agentfactory.cpp
	chanagents/chanagent.cpp
	chanagents/defaultagent.cpp
	chanagents/standardagentfactory.cpp
	chanlist.cpp
	chanmanager.cpp
	chanwatcher.cpp
	contentpipe.cpp
	coding/coder.cpp
	coding/codingmanager.cpp
	coding/signaturecoder.cpp
	components/componentvisibility.cpp
	components/attachment.cpp
	components/board.cpp
	components/chan.cpp
	components/post.cpp
	components/postid.cpp
	components/thread.cpp
	components/threadid.cpp
	components/threadptr.cpp
	watermarking/watermarkgenerator.cpp
	watermarking/watermarkgeneratorfactory.cpp
	watermarking/textwatermarkgenerator.cpp
	watermarking/imagewatermarkgenerator.cpp
	watermarking/whitespacewatermarkgenerator.cpp
	watermarking/watermark.cpp
	extracontainer.cpp
	filter.cpp
	filterlist.cpp
	filtertext.cpp
	filterwipe.cpp
	imagestorage.cpp
	keymap.cpp
	keymapmanager.cpp
	log.cpp
	mimetypes.cpp
#	network/connector.cpp
	network/cookiestorage.cpp
#	network/request.cpp
#	network/httprequest.cpp
#	network/httpconnector.cpp
	notification/notification.cpp
	notification/notificationmanager.cpp
	notification/notificator.cpp
	notification/notificationnewmessages.cpp
	spellcheck/dummyspellchecker.cpp
	spellcheck/spellchecker.cpp
	spellcheck/spellcheckermanager.cpp
	sqlite3/CppSQLite3.cpp
	sqlite3/sqlite3.c
	dummythreadstorage.cpp
	sqlitethreadstorage.cpp
	standardchanmanager.cpp
	task.cpp
	taskhub.cpp
	tasks/taskrequest.cpp
	tasks/tasksavethread.cpp
	tasks/taskboardrequest.cpp
	tasks/taskthreadrequest.cpp
	tasks/taskthumbnailrequest.cpp
	tasks/taskattachmentrequest.cpp
	tasks/tasksendpost.cpp
	templatethreadbuilder.cpp
	text.cpp
	threadbuilder.cpp
	threadbuilderfactory.cpp
	threadsaver.cpp
	threadstorage.cpp
	timestampparser.cpp
	ui/addressbar.cpp
	ui/addressbarelement.cpp
	ui/boardsettingsdialog.cpp
	ui/chanlisteditor.cpp
	ui/exportthreaddialog.cpp
	ui/filteredit.cpp
	ui/imageeditor/colorwidget.cpp
	ui/imageeditor/editortool.cpp
	ui/imageeditor/imageeditarea.cpp
	ui/imageeditor/imageeditor.cpp
	ui/imageeditor/newimagedialog.cpp
	ui/imageeditor/toolpencil.cpp
	ui/imageeditor/toolfill.cpp
	ui/imageeditor/toolselection.cpp
	ui/imagelist.cpp
	ui/imagemanager.cpp
	ui/imageview.cpp
	ui/imagewidget.cpp
	ui/mainwindow.cpp
	ui/mainwindowcontroller.cpp
	ui/newchandialog.cpp
	ui/featuresdialog.cpp
	ui/postdocument.cpp
	ui/postedit.cpp
	ui/postitemdelegate.cpp
	ui/postitemmodel.cpp
	ui/postitemview.cpp
	ui/postwidget.cpp
	ui/postwidgetelement.cpp
	ui/poststyle.cpp
	ui/settingsframe.cpp
	ui/spellcheckhighlighter.cpp
	ui/tasklist.cpp
	ui/threaditemdelegate.cpp
	ui/threaditemmodel.cpp
	ui/threadoverviewdelegate.cpp
	ui/templatethreadbuilderconfig.cpp
	ui/threadmodel.cpp
	ui/threadlistmodel.cpp
	paths.cpp
	libwishmaster.cpp
	wishmasterapplication.cpp
)

SET(wishmaster_ui
		ui/boardsettingsdialog.ui
		ui/chanlisteditor.ui
		ui/filteredit.ui
		ui/imageeditor/imageeditor.ui
		ui/imagelist.ui
		ui/imageeditor/newimagedialog.ui
		ui/imagemanager.ui
		ui/featuresdialog.ui
		ui/imageview.ui
		ui/mainwindow.ui
		ui/newchandialog.ui
		ui/postedit.ui
		ui/settingsframe.ui
		ui/exportthread.ui
		ui/templatethreadbuilderconfig.ui
   )

SET(wishmaster_moc
	analyzers/analyzer.h
	analyzers/extractor.h
	analyzers/raranalyzer.h
	analyzers/zipanalyzer.h
	boardparsers/boardparser.h
	boardparsers/parserfactory.h
	captchafetchers/captchafetcher.h
	captchafetchers/captchafetcherfactory.h
	captchafetchers/genericcaptchafetcher.h
	captchafetchers/genericcaptchafetcher_impl.h
	chanagents/agentfactory.h
	chanagents/chanagent.h
	chanagents/defaultagent.h
	chanagents/standardagentfactory.h
	chanlist.h
	chanmanager.h
	chanwatcher.h
	contentpipe.h
	components/componentvisibility.h
	components/attachment.h
	components/board.h
	components/chan.h
	components/post.h
	components/postid.h
	components/thread.h
	components/threadid.h
	components/threadptr.h
	coding/coder.h
	coding/codingmanager.h
	coding/signaturecoder.h
	watermarking/watermarkgenerator.h
	watermarking/watermarkgeneratorfactory.h
	watermarking/textwatermarkgenerator.h
	watermarking/imagewatermarkgenerator.h
	watermarking/whitespacewatermarkgenerator.h
	watermarking/watermark.h
	extracontainer.h
	extrainfo.h
	filter.h
	filterlist.h
	filtertext.h
	filterwipe.h
	imagestorage.h
	keymap.h
	keymapmanager.h
	mimetypes.h
#	network/connector.h
	network/cookiestorage.h
#	network/request.h
#	network/httprequest.h
#	network/httpconnector.h
	notification/notification.h
	notification/notificationmanager.h
	notification/notificator.h
	notification/notificationnewmessages.h
	spellcheck/dummyspellchecker.h
	spellcheck/spellchecker.h
	spellcheck/spellcheckermanager.h
	singleton.h
	dummythreadstorage.h
	sqlitethreadstorage.h
	standardchanmanager.h
	task.h
	taskhub.h
	tasks/taskrequest.h
	tasks/tasksavethread.h
	tasks/taskboardrequest.h
	tasks/taskthreadrequest.h
	tasks/taskthumbnailrequest.h
	tasks/taskattachmentrequest.h
	tasks/tasksendpost.h
	templatethreadbuilder.h
	text.h
	threadbuilderfactory.h
	threadbuilder.h
	threadsaver.h
	threadstorage.h
	timestampparser.h
	ui/addressbar.h
	ui/addressbarelement.h
	ui/boardsettingsdialog.h
	ui/chanlisteditor.h
	ui/exportthreaddialog.h
	ui/filteredit.h
	ui/imageeditor/colorwidget.h
	ui/imageeditor/editortool.h
	ui/imageeditor/imageeditarea.h
	ui/imageeditor/imageeditor.h
	ui/imageeditor/newimagedialog.h
	ui/imageeditor/toolpencil.h
	ui/imageeditor/toolfill.h
	ui/imageeditor/toolselection.h
	ui/imagelist.h
	ui/imagemanager.h
	ui/imageview.h
	ui/imagewidget.h
	ui/mainwindow.h
	ui/mainwindowcontroller.h
	ui/newchandialog.h
	ui/featuresdialog.h
	ui/postdocument.h
	ui/postedit.h
	ui/postitemdelegate.h
	ui/postitemmodel.h
	ui/postitemview.h
	ui/postwidget.h
	ui/postwidgetelement.h
	ui/poststyle.h
	ui/settingsframe.h
	ui/spellcheckhighlighter.h
	ui/tasklist.h
	ui/threaditemdelegate.h
	ui/threaditemmodel.h
	ui/threadoverviewdelegate.h
	ui/templatethreadbuilderconfig.h
	ui/threadmodel.h
	ui/threadlistmodel.h
	libwishmaster.h
	wishmasterapplication.h
	)

IF(HUNSPELL_FOUND)
	MESSAGE("-- Hunspell found")
	SET(wishmaster_sources ${wishmaster_sources} spellcheck/hunspell_spellchecker.cpp)
	SET(wishmaster_moc ${wishmaster_moc} spellcheck/hunspell_spellchecker.h) # Just in case
	SET(spelling_libs ${HUNSPELL_LIBRARIES})
	ADD_DEFINITIONS(-DHUNSPELL_FOUND)
ENDIF(HUNSPELL_FOUND)

QT4_WRAP_UI(UI_HEADERS ${wishmaster_ui})
QT4_WRAP_CPP(MOC_SRCS ${wishmaster_moc})
QT4_ADD_RESOURCES(RSRCS ../wishmaster.qrc)

if (RELOAD_TRANSLATIONS)
	QT4_CREATE_TRANSLATION(qms i18n ${wishmaster_sources} ${UI_HEADERS}
		../i18n/russian.ts ../i18n/english.ts)
	message( "" )  
else (NOT RELOAD_TRANSLATIONS)
	QT4_ADD_TRANSLATION(qms
		../i18n/russian.ts ../i18n/english.ts)
	message( "" )
endif (RELOAD_TRANSLATIONS)

INCLUDE_DIRECTORIES(../wishmaster2-network/include)

ADD_LIBRARY(wm SHARED ${wishmaster_sources} ${UI_HEADERS} ${MOC_SRCS} ${RSRCS} ${qms})
TARGET_LINK_LIBRARIES(wm ${spelling_libs} wishmaster2-network)
INSTALL(FILES ${qms} DESTINATION ${SHAREDIR}/i18n)

INSTALL(TARGETS wm LIBRARY DESTINATION ${ROOTLIBDIR})

